package com.shkg.opencloud.fastdfs.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author
 * @date 2019/8/6
 */

@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Value("${sys.swagger.basePackage}")
    private String basePackage;
    @Value("${sys.swagger.title}")
    private String title;
    @Value("${sys.swagger.description}")
    private String description;
    @Value("${sys.swagger.contact}")
    private String contact;
    @Value("${sys.swagger.version}")
    private String version;

    public Swagger2Config() {
    }

    @Bean
    public Docket createRestApi() {
        return (new Docket(DocumentationType.SWAGGER_2)).apiInfo(this.apiInfo()).select().apis(RequestHandlerSelectors.basePackage(this.basePackage)).paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo() {
        return (new ApiInfoBuilder()).title(this.title).description(this.description).contact(this.contact).version(this.version).build();
    }
}
